class Solution:
    def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
        protect = ListNode()
        #
        tail = protect
        head1 = list1
        head2 = list2
        while head1 and head2:
            if head1.val < head2.val:
                tail.next = head1
                tail = head1
                head1 = head1.next
                
            else:
                tail.next = head2
                head2 = head2.next
                tail = tail.next

        if not head1:
            tail.next = head2
        if not head2:
            tail.next = head1
        print("protect val2 is {}".format(protect.next.val))
        return protect.next